<template>
  <view class="order-wrap">
    <view class="nav-bar-wrap">
      <uni-nav-bar :border="false" class="uni-nav-bar" :fixed="true" status-bar left-icon="left" :title="'我的订单'|i18n" @clickLeft="back" />
    </view>
    <view class="tabs">
      <view @click="onTab(index)" class="tab-item" :class="{'current-item': currentTabIndex === index}" v-for="(tab, index) in tabs" :key="tab.value">
       {{tab.label|i18n}}
      </view>
    </view>
    <view class="order-list-wrap">
      <illegal-order v-if="currentTabIndex === 0" />
      <electricity-order v-else-if="currentTabIndex === 1" />
      <telephone-charges-order v-else-if="currentTabIndex === 2"/>
      <traffic-order v-else-if="currentTabIndex === 3"/>
        <train-order v-else-if="currentTabIndex === 4"/>
        <plan-order v-else-if="currentTabIndex === 5"/>
    </view>
  </view>
</template>
<script>
import electricityOrder from "../components/electricityOrder";
import illegalOrder from "../components/illegalOrder";
import telephoneChargesOrder from "../components/telephoneChargesOrder";
import trafficOrder from "../components/trafficOrder";
import trainOrder from "../components/train.vue";
import planOrder from "../components/air.vue";
import {ORDER_TABS_ARRAY} from "../../../consts";

export default {
  name: "orderList",
  components: {
    illegalOrder, // 违章
    electricityOrder, // 电费
    telephoneChargesOrder, // 电话费
    trafficOrder, // 流量
	trainOrder, // 火车票
      planOrder// 机票
  },
  data () {
    return {
      currentTabIndex: 4,
      tabs: ORDER_TABS_ARRAY
    }
  },
  onLoad (option) {
    const {orderType} = option
    const currentTabIndex = ORDER_TABS_ARRAY.findIndex(e => e.value === orderType)
  },
  onShow() {
    this.currentTabIndex = 0
  },
  methods: {
    back() {
      uni.navigateBack()
    },
    onTab (index) {
      this.currentTabIndex = index
    }
  }
}
</script>

<style lang="less" scoped>
  .order-wrap {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }
  .tabs {
    width: 100%;
    display: inline-flex;
  }
  .tab-item {
    overflow: hidden;
    transition: .2s;
    position: relative;
    box-sizing: border-box;
    flex: 1;
    text-align: center;
    padding: 30upx 0;
    font-size: 24upx;
    font-weight: 400;
    color: #999999;
    background: #ffffff;
    line-height: 24upx;
  }
  .tab-item.current-item {
    color: #333333;
    font-weight: 500;
    background-color: #FDD04B
  }
  .tab-item.current-item:before {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    left: 0;
    bottom: 0;
    background-color: #E9631F;
  }
  .order-list-wrap {
    min-height: 0;
    flex: 1;
  }
  .uni-nav-bar {
    /deep/ .uni-navbar__content {
      background: linear-gradient(180deg, #FDD048 0%, #FAF6ED 100%) !important;
      .uni-navbar__header {
        background: transparent !important;
      }
    }
  }

</style>
